import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'

// 表单校验
export const rules = reactive({
  status: [required],
  type: [required]
})

// CrudSchema https://doc.crc.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
  // {
  //   label: '编号',
  //   field: 'id',
  //   isForm: false
  // },
  {
    label: '事件描述',
    field: 'content',
    isSearch: true,
    form: {
      component: 'Editor',
      componentProps: {
        valueHtml: '',
        height: 200
      }
    }
  },
  {
    label: '事件类型',
    field: 'type',
    isSearch: true,
    isForm: false,
    dictType: DICT_TYPE.SYSTEM_CUNQING_TYPE,
    search: {
      formItemProps: {
        style: {
          width: '260px'
        }
      }
    }
  },
  {
    label: '上报人',
    field: 'createName',
    isSearch: false,
    form: {
      component: 'InputNumber',
      value: 0
    }
  },
  {
    label: '上报时间',
    field: 'createTime',
    formatter: dateFormatter,
    isSearch: false,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    isForm: false
  },
  {
    label: '任务状态',
    field: 'status',
    isSearch: true,
    isForm: false,
    dictType: DICT_TYPE.SYSTEM_CUNSTATE_TYPE,
    search: {
      formItemProps: {
        style: {
          width: '260px'
        }
      }
    }
  },

  {
    label: '处理结果',
    field: 'result',
    isSearch: false
  },

  {
    label: '评价分数',
    field: 'rating'
  },
  {
    label: '标题',
    field: 'title',
    isSearch: false,
    isTable: false,
    isForm: false
  },
  {
    label: '操作',
    field: 'action',
    isForm: false,
    table: {
      width: '300px'
    }
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
